<!DOCTYPE html>
<html id="iframe">
<head>
    <meta charset="UTF-8">

    <title>{:C('sitename')}</title>

    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="telephone=no,email=no"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta name="telephone=no"  content="format-detection">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no" />

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/lib.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/index.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/page.css"/>

</head>
<style>
    .content p{
        display: inline-block;
    }
    .keyborad{
        display: none;position: absolute;top:50px;left:0px;z-index: 10;padding: 3px;
        margin:0 !important;border-radius: 6px;background-color: #c7d0d6;
        width:100%;
    }
    .keyborad p{width: 100%;margin:5px 0;text-align: center;}
    .keyborad p span{
        display: inline-block;width: 13%;height: 40px;line-height:40px;background-color: #6d7580;color:#FFF;
        text-align: center;border-radius: 3px;
    }
    .keyborad strong{display: inline-block;width:15%;border-radius: 3px;height:40px;line-height: 40px;color:#FFF;}
    .keyborad .qc{background-color: #f00;float: left;}
    .keyborad .jt{background-color: #00ff7a;float: left;}
    .keyborad .fs{background-color: #008dff;width: 30%}
    .keyborad .close{background-color: #c06215;float: right;}

    .portrait img{    border-radius: 50px;width: 50px;height: 50px;    margin: 10px auto;}
    .chatting{ padding: 0 10px;}
    .main-box{ padding: 0 10px;}
    .fix {
        width: 100%;
        height: 46px;
        background: black;
        position: fixed;
        bottom: 0;
        text-align: center;
        line-height: 46px;
        color: white;
    }
</style>
<body onload="connect();">
<!--<div class="top fix" style="position: fixed;left:0;bottom:0;z-index: 999999;">

    <input id="textarea" type="text" class="jp_btn_input" required placeholder="名次/玩法/金额" style="padding-left:5px;padding-right: 5px;" />

    <button class="submit_btn"  onclick="onSubmit(); return false;"  >发送</button>
    <button class="zhicwl-xiaz" >快捷下注</button>


</div>-->
<link rel="stylesheet" type="text/css" href="/Public/Home/css/zhicwl-z.css">
<style>
    .zhicwl-qiejlf-tab-06 .zhicwl-akodr dl dt{
        width: 20%;
    }
</style>
<div class="zhicwl-csplr" id="zhicwl-csplrs" style="display: none;">

    <div class="zhicwl-yrlof">
        <div class="zhicwl-arwort">
            <div class="zhicwl-arwort-div">
                <dl class="zhicwl-tc-01 display-box box-align-center">
                    <dt ino="1" class="on"><span>猜大小单双</span></dt>
                    <dt ino="2" class=""><span>猜组合</span></dt>
                    <dt ino="3" class=""><span>猜和值</span></dt>
                    <div class="zhicwl-hdrte">
                        <h6>&nbsp;</h6>
                        <div class="zhicwl-hdrte-nav">
                            <ul>
                                <li itx="7" >猜极值</li>
                                <li itx="8"  >猜类型</li>
                            </ul>
                        </div>
                    </div>

                </dl>
            </div>
        </div>
    </div>

    <section class="zhicwl-qiejlf">
        <!--猜大小单双-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-06" style="display: block;">
            <div class="zhicwl-ldprta display-box box-align-center">
                <h2 class="zhicwl-ldprta-left box-flex">猜大小单双</h2>
                <div class="zhicwl-repavb zhicwl-guanb"><span>X</span></div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt style="width: 50%;text-align: center;">
                            <div>
                                <span>大</span>
                                <p>特码大于等于14</p>
                                <samp>x {:C('bj28_1_dxds')}</samp>
                            </div>
                        </dt>
                        <dt style="width: 50%;text-align: center;">
                            <div>
                                <span>小</span>
                                <p>特码小于等于13</p>
                                <samp>x {:C('bj28_1_dxds')}</samp>
                            </div>
                        </dt>
                        <dt style="width: 50%;text-align: center;">
                            <div>
                                <span>单</span>
                                <p>特码数为单</p>
                                <samp>x {:C('bj28_1_dxds')}</samp>
                            </div>
                        </dt>
                        <dt style="width: 50%;text-align: center;">
                            <div>
                                <span>双</span>
                                <p>特码数为双</p>
                                <samp>x {:C('bj28_1_dxds')}</samp>
                            </div>
                        </dt>
                    </dl>
                </div>
            </div>
        </div>
        <!--/猜大小单双-->
        <!--猜组合-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-06 zhicwl-gaulep" style="display: none;">
            <div class="zhicwl-ldprta display-box box-align-center">
                <h2 class="zhicwl-ldprta-left box-flex">猜组合</h2>
                <div class="zhicwl-repavb zhicwl-guanb"><span>X</span></div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt>
                            <div>
                                <span>大单</span>
                                <samp>x {:C('bj28_1_zuhe_1')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>小单</span>
                                <samp>x {:C('bj28_1_zuhe_2')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>大双</span>
                                <samp>x {:C('bj28_1_zuhe_2')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>小双</span>
                                <samp>x {:C('bj28_1_zuhe_1')}</samp>
                            </div>
                        </dt>

                    </dl>
                </div>
            </div>
        </div>
        <!--/猜组合-->
        <!--猜和值-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-06" style="display: none;">
            <div class="zhicwl-ldprta display-box box-align-center">
                <h2 class="zhicwl-ldprta-left box-flex">猜和值</h2>
                <div class="zhicwl-repavb zhicwl-guanb"><span>X</span></div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt>
                            <div>
                                <span>0</span>
                                <samp>x {:C('bj28_1_tema_0')}</samp>
                            </div>
                        </dt>


                        <dt>
                            <div>
                                <span>1</span>
                                <samp>x {:C('bj28_1_tema_1')}</samp>
                            </div>
                        </dt>

                        <dt>
                            <div>
                                <span>2</span>
                                <samp>x {:C('bj28_1_tema_2')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>3</span>
                                <samp>x {:C('bj28_1_tema_3')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>4</span>
                                <samp>x {:C('bj28_1_tema_4')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>5</span>
                                <samp>x {:C('bj28_1_tema_5')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>6</span>
                                <samp>x {:C('bj28_1_tema_6')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>7</span>
                                <samp>x {:C('bj28_1_tema_7')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>8</span>
                                <samp>x {:C('bj28_1_tema_8')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>9</span>
                                <samp>x {:C('bj28_1_tema_9')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>10</span>
                                <samp>x {:C('bj28_1_tema_10')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>11</span>
                                <samp>x {:C('bj28_1_tema_11')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>12</span>
                                <samp>x {:C('bj28_1_tema_12')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>13</span>
                                <samp>x {:C('bj28_1_tema_13')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>14</span>
                                <samp>x {:C('bj28_1_tema_13')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>15</span>
                                <samp>x {:C('bj28_1_tema_12')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>16</span>
                                <samp>x {:C('bj28_1_tema_11')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>17</span>
                                <samp>x {:C('bj28_1_tema_10')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>18</span>
                                <samp>x {:C('bj28_1_tema_9')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>19</span>
                                <samp>x {:C('bj28_1_tema_8')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>20</span>
                                <samp>x {:C('bj28_1_tema_7')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>21</span>
                                <samp>x {:C('bj28_1_tema_6')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>22</span>
                                <samp>x {:C('bj28_1_tema_5')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>23</span>
                                <samp>x {:C('bj28_1_tema_4')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>24</span>
                                <samp>x {:C('bj28_1_tema_3')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>25</span>
                                <samp>x {:C('bj28_1_tema_2')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>26</span>
                                <samp>x {:C('bj28_1_tema_1')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>27</span>
                                <samp>x {:C('bj28_1_tema_0')}</samp>
                            </div>
                        </dt>

                    </dl>
                </div>
            </div>
        </div>
        <!--/猜和值-->

        <!--猜极值-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-06 zhicwl-gaulep" style="display: none;">
            <div class="zhicwl-ldprta display-box box-align-center">
                <h2 class="zhicwl-ldprta-left box-flex">猜极值</h2>
                <div class="zhicwl-repavb zhicwl-guanb"><span>X</span></div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt>
                            <div>
                                <span>极大</span>
                                <samp>x {:C('bj28_1_jdx')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>极小</span>
                                <samp>x {:C('bj28_1_jdx')}</samp>
                            </div>
                        </dt>

                    </dl>
                </div>
            </div>
        </div>
        <!--/猜极值-->



        <!--猜类型-->
        <div class="zhicwl-qiejlf-tab zhicwl-qiejlf-tab-06 zhicwl-gaulep" style="display: none;">
            <div class="zhicwl-ldprta display-box box-align-center">
                <h2 class="zhicwl-ldprta-left box-flex">猜类型</h2>
                <div class="zhicwl-repavb zhicwl-guanb"><span>X</span></div>
            </div>

            <div class="zhicwl-keapr">
                <div class="zhicwl-akodr">
                    <dl>
                        <dt>
                            <div>
                                <span>豹子</span>
                                <samp>x {:C('bj28_1_bds_1')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>顺子</span>
                                <samp>x {:C('bj28_1_bds_2')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>对子</span>
                                <samp>x {:C('bj28_1_bds_3')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>半顺</span>
                                <samp>x {:C('bj28_1_bds_4')}</samp>
                            </div>
                        </dt>
                        <dt>
                            <div>
                                <span>杂六</span>
                                <samp>x {:C('bj28_1_bds_5')}</samp>
                            </div>
                        </dt>

                    </dl>
                </div>
            </div>
        </div>
        <!--/猜类型-->

    </section>
</div>

<div class="main-box">
    <!--第一行（表单、积分在线人数）-->
    <p style="line-height: 30px;">
        游戏点数：<font color="red"><span id="sy">{$userinfo.points}</span></font>点
        <b style="float: right;font-weight: 400;">在线人数：<span id="xs" style="font-weight: bold"></span>人</b>
    </p>
    <!--<div class="top" style="position: fixed;left:0;bottom:0;z-index: 999999;">-->
    <!--<span class="jp_btn"></span>-->
    <!--<input id="textarea" type="text" class="jp_btn_input" required placeholder="名次/玩法/金额" style="padding-left:5px;padding-right: 5px;" />-->

    <!--<button class="submit_btn"  onclick="onSubmit(); return false;"  >发送</button>-->
    <!--<button class="zhicwl-xiaz" >快捷下注</button>-->

    <!--<div class="keyborad">-->
    <!--<p>-->
    <!--<span>1</span>-->
    <!--<span>2</span>-->
    <!--<span>3</span>-->
    <!--<span>4</span>-->
    <!--<span>5</span>-->
    <!--<span>/</span>-->
    <!--<span>-</span>-->
    <!--</p>-->
    <!--<p>-->
    <!--<span>6</span>-->
    <!--<span>7</span>-->
    <!--<span>8</span>-->
    <!--<span>9</span>-->
    <!--<span>0</span>-->
    <!--<span>杂六</span>-->
    <!--<span>.</span>-->
    <!--</p>-->
    <!--<p>-->
    <!--<span>大</span>-->
    <!--<span>小</span>-->
    <!--<span>单</span>-->
    <!--<span>双</span>-->
    <!--<span>豹子</span>-->
    <!--<span>顺子</span>-->
    <!--<span>对子</span>-->
    <!--</p>-->

    <!--<p>-->
    <!--<span>庄</span>-->
    <!--<span>闲</span>-->
    <!--<span>和</span>-->
    <!--<span>点</span>-->
    <!--<span>极大</span>-->
    <!--<span>极小</span>-->
    <!--<span>半顺</span>-->
    <!--</p>-->
    <!--<p>-->
    <!--<strong class="qc">清除</strong>-->
    <!--<strong class="jt">←</strong>-->
    <!--<strong class="fs">发送</strong>-->
    <!--<strong class="close">关闭</strong>-->
    <!--</p>-->
    <!--</div>-->
    <!--</div>-->
</div>
<div id="load" style="text-align: center;font-size: 14px;color:#fff;">加载中...</div>
<div class="chatting" style="display: none;">
    <volist name="list" id="vo">
        <if condition="$vo['type'] eq 'admin'">
            <div <if condition="$vo.uid eq $userinfo['id']">class="chatting-li qtr green"<else/>class="chatting-li qtr orange"</if> >
            <div class="portrait"><img src="{$vo.head_img_url}"/></div>
            <div class="content">
                <small><span class="name">{$vo.from_client_name}</span><time>{$vo.time}</time></small>
                <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
            </div>
</div>
</if>
<if condition="$vo['type'] eq 'system'">
    <div class="chatting-li qtr pink">
        <div class="portrait"><img src="{$vo.head_img_url}"/></div>
        <div class="content">
            <small><span class="name">{$vo.from_client_name}</span><time>{$vo.time}</time></small>
            <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
        </div>
    </div>
</if>
<if condition="$vo['type'] eq 'say'">
    <div <if condition="$vo.uid eq $userinfo['id']">class="chatting-li green"<else/>class="chatting-li"</if> >
    <div class="portrait"><img src="{$vo.head_img_url}"/></div>
    <div class="content">
        <small><span class="name">{$vo.from_client_name}</span><time>{$vo.time}</time></small>
        <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
    </div>
    </div>
</if>
<if condition="$vo['type'] eq 'error' && $userinfo['id'] eq $vo['uid']">
    <div class="chatting-li qtr green">
        <div class="portrait"><img src="{$vo.head_img_url}"/></div>
        <div class="content">
            <small><span class="name">{$vo.from_client_name}</span><time>{$vo.time}</time></small>
            <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
        </div>
    </div>
</if>
<if condition="$vo['type'] eq 'say_error' && $userinfo['id'] eq $vo['uid']">
    <div class="chatting-li green">
        <div class="portrait"><img src="{$vo.head_img_url}"/></div>
        <div class="content">
            <small><span class="name">{$vo.from_client_name}</span><time>{$vo.time}</time></small>
            <p>{$vo.content|htmlspecialchars_decode|stripcslashes}</p>
        </div>
    </div>
</if>
</volist>
</div>

<script src='//cdn.bootcss.com/jquery/1.11.3/jquery.js'></script>
<!--聊天-->
<script type="text/javascript" src="__PUBLIC__/worker/js/swfobject.js"></script>
<script type="text/javascript" src="__PUBLIC__/worker/js/web_socket.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script type="text/javascript">

    scrollFixed()
    $(parent.window).resize(function() {
        scrollFixed()
    })
    function scrollFixed (){
        $(".fix").css({
            top : $(parent.window).scrollTop()+380,
            // marginTop: $(window.parent).height() - 174
        });
        $(parent.window).scroll(function() {
            $(".fix").css({
                top : $(parent.window).scrollTop()+380,
                // marginTop: $(window.parent).height() -174

            });
        });
    }


    setTimeout(function() {
        $('#load').css('display','none');
        $('.chatting').css('display','block');
    }, 1500);


    $('.jp_btn').click(function(){
        if ($('.keyborad').is(":hidden")) {
            $('.keyborad').show();
        } else {
            $('.keyborad').hide();
        }

    })

    $('.keyborad span').click(function(){
        var value = $(this).text();
        var input_value = $('#textarea').val();
        $('#textarea').val(input_value+value);
    })

    $('.keyborad .qc').click(function(){
        $('#textarea').val('');
    })

    $('.keyborad .jt').click(function(){
        var input_value = $('#textarea').val();
        var str = input_value.substr(0,input_value.length-1);
        $('#textarea').val(str);
    })

    $('.keyborad .fs').click(function(){
        $('.submit_btn').click();
        $('.keyborad').hide();
    })

    $('.keyborad .close').click(function(){
        $('.keyborad').hide();
    })

    $('.submit_btn').click(function(){
        $('.keyborad').hide();
    })
    // $('#textarea').blur(function(){
    // 	$('.keyborad').hide();
    // })


    document.onkeydown=function(event){
        e = event ? event :(window.event ? window.event : null);
        if(e.keyCode==13){
            onSubmit(); return false;
        }
    }

    if(typeof console == "undefined") {
        this.console = {
            log: function(msg) {}
        };
    }
    WEB_SOCKET_SWF_LOCATION = "__PUBLIC__/worker/swf/WebSocketMain.swf";
    WEB_SOCKET_DEBUG = true;
    var ws, name;

    // 连接服务端
    function connect(){
        // 创建websocket
        ws = new WebSocket("ws://" + document.domain + ":9000");
        // 当socket连接打开时，发送登录信息
        ws.onopen = function(){
            var name = "{$userinfo.nickname}";
            // 登录
            var userid = "{$userinfo.id}";
            var login_data = '{"type":"login","client_name":"' + name.replace(/"/g, '\\"') + '","client_id":"'+userid+'"}';
            console.log("websocket握手成功，发送登录数据:" + login_data);
            ws.send(login_data);
        };
        // 当有消息时根据消息类型显示不同信息
        ws.onmessage = onmessage;
        ws.onclose = function(){
            console.log("连接关闭，定时重连");
            connect();
        };
        ws.onerror = function() {
            console.log("出现错误");
        };
    }

    var inte = parseInt(Math.random()*12+1);
    var inte_fen = parseInt(Math.random()*100+6);
    function onmessage(e) {
        var rate = 0;
        var robot_rate = {:C('robot_rate')} ? {:C('robot_rate')} : 3;
        switch({:C('robot_rate')}){
        case 5:
            rate = 5;
            break;
        case 4:
            rate = 10;
            break;
        case 3:
            rate = 25;
            break;
        case 2:
            rate = 35;
            break;
        case 1:
            rate = 45;
            break;
        default:
            rate = 25;
            break;
        }
        //console.log(e.data);
        var data = eval("(" + e.data + ")");
        switch(data['type']) {
            // 服务端ping客户端
            case 'ping':
                $('#xs').html(data.content+{:C('online')}+parseInt(Math.random()*4));
        ws.send('{"type":"pong"}');
        break;

    case 'ping_robot_rate':
        ws.send('{"type":"robot"}');
        break;

    case 'ping_robot_fen':
        ws.send('{"type":"fen"}');
        break;
        // 登录 更新用户列表
    case 'login':
        console.log(data['client_name'] + "登录成功");
        break;
        // 发言
    case 'say':
        say(data['uid'],data['from_client_name'], data['head_img_url'], data['content'], data['time']);
        break;
        // 用户退出 更新用户列表
    case 'logout':
        break;
    case 'broadcast':
        //alert('client');

        //房管
    case 'admin':
        if('{$userinfo.id}'==data['uid']){
            $(".chatting").prepend('<div class="chatting-li qtr green"><div class="portrait"><img src="'+data['head_img_url']+'"/></div><div class="content"><small><span class="name">' + data["from_client_name"] +'</span><time>'+data["time"] +'</time></small><p>' + data["content"] + '</p></div></div>');
        }else{
            $(".chatting").prepend('<div class="chatting-li qtr orange"><div class="portrait"><img src="'+data['head_img_url']+'"/></div><div class="content"><small><span class="name">' + data["from_client_name"] +'</span><time>'+data["time"] +'</time></small><p>' + data["content"] + '</p></div></div>');
        }
        break;
        //系统
    case 'system':
        if('{$userinfo.id}'==data['uid']){
            $(".chatting").prepend('<div class="chatting-li qtr green"><div class="portrait"><img src="'+data['head_img_url']+'"/></div><div class="content"><small><span class="name">' + data["from_client_name"] +'</span><time>'+data["time"] +'</time></small><p>' + data["content"] + '</p></div></div>');
        }else{
            $(".chatting").prepend('<div class="chatting-li qtr orange"><div class="portrait"><img src="'+data['head_img_url']+'"/></div><div class="content"><small><span class="name">' + data["from_client_name"] +'</span><time>'+data["time"] +'</time></small><p>' + data["content"] + '</p></div></div>');
        }
        break;
    case 'addfen':
        $(".chatting").prepend('<div class="chatting-li qtr pink"><div class="portrait"><img src="/Public/main/img/system.jpg"/></div><div class="content"><small><span class="name">客服</span><time>'+data["time"]+'</time></small><p>' + data["content"] + '</p></div></div>');
        break;
        //积分减
    case 'points':
        $('#sy').html((parseFloat($('#sy').html())-data['content']).toFixed(1));
        break;
        //积分加
    case 'pointsadd':
        $('#sy').html((parseFloat($('#sy').html())+data['points']).toFixed(1));
        parent.layer.msg('恭喜竞猜成功');
        break;
        //重载
    case 'reload':
        if('{$userinfo.id}'==9){
            window.location.href=window.location.href;
        }
        break;
        //切换
    case 'switch':
        parent.location.reload();
        break;
    }
    }


    function wsTz(tz,money){
        var headimgurl = '{$userinfo.headimgurl}';
        var from_client_name = '{$userinfo.nickname}';
        for (var i = 0; i < tz.length; i++) {
            var input = tz[i];
            ws.send('{"type":"say","client_name":"' + from_client_name + '","headimgurl":"' + headimgurl + '","content":"' + input.replace(/"/g, '\"').replace(/n/g, '\n').replace(/r/g, '\r').replace(/##/g, money) + '"}');
        }
        $('#textarea').val('');
        $(".zhicwl-qiejlf .zhicwl-qiejlf-tab .zhicwl-keapr dt").removeClass('on');
        $(".zhicwl-fxalpr-an1").removeClass('on');
        $('.zhicwl-guanb').click();
    }
    function checkData(){

        var tz = [];
        var hms="";
        $.each($('.zhicwl-qiejlf .zhicwl-qiejlf-tab'), function(k, v){
            if ($(this).css('display') == 'block'){
                switch (k) {
                    case 0:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'##');
                            }

                        })

                        break;
                    case 1:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'##');
                            }

                        })

                        break;
                    case 2:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'点'+'##');
                            }

                        })

                        break;
                    case 3:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'##');
                            }

                        })
                        break;
                    case 4:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'##');
                            }

                        })
                        break;
                    case 5:
                        tz = [];
                        $(this).find('.zhicwl-keapr .zhicwl-akodr dt').each(function(i){
                            if($(this).hasClass('on')){
                                tz.push($(this).find('span').text()+'##');
                            }

                        })

                        break;

                }
            }
        });

        if(tz.length>0){
            return tz;
        }else{
            alert("请选择玩法");
            return false;
        }
    }


    // 提交对话
    function onSubmit() {

        var headimgurl = '{$userinfo.headimgurl}';
        var input = window.parent.document.getElementById("textarea");
        var from_client_name = '{$userinfo.nickname}';
        if(input.value==''){
            $('#textarea').focus();
            return false;
        }
        ws.send('{"type":"say","client_name":"'+from_client_name+'","headimgurl":"'+headimgurl+'","content":"' + input.value.replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r') + '"}');
        $('#textarea').val('');
        //$('#dialog').scrollTop(0);
    }

    // 发言
    function say(uid, from_client_name, head_img_url, content, time) {
        if('{$userinfo.id}'==uid){
            $(".chatting").prepend('<div class="chatting-li green"><div class="portrait"><img src="'+head_img_url+'"/></div><div class="content"><small><span class="name">' + from_client_name +'</span><time>'+time +'</time></small><p>' + content + '</p></div></div>');
        }else{
            $(".chatting").prepend('<div class="chatting-li"><div class="portrait"><img src="'+head_img_url+'"/></div><div class="content"><small><span class="name">' + from_client_name +'</span><time>'+time +'</time></small><p>' + content + '</p></div></div>');
        }
    }
</script>
<!--聊天-->

<!--推送-->
<script src='//cdn.bootcss.com/socket.io/1.3.7/socket.io.js'></script>
<script>
    var uid = '{$userinfo.id}';
</script>
<script>
    function escape2Html(str) {
        var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
        return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
    }
    $(document).ready(function() {
        // 连接服务端
        var socket = io('http://' + document.domain + ':2126');
        // 连接后登录
        socket.on('connect', function() {
            socket.emit('login', uid);
        });
        // 后端推送来消息时
        socket.on('new_msg', function(msg) {
            var data = eval("(" + escape2Html(msg) + ")");
            if (data['type'] == '3' || data['type'] == '4' || data['type'] == '1' ||data['type'] == '2') {
                return false;
            }
            var time = data['time'];
            var content = data['content'];
            if(data['points'] && data['to']=='{$userinfo.id}'){
                var points = parseFloat($('#sy').html())+parseFloat(data['points']);
                $('#sy').html(points);
            }
            $(".chatting").prepend('<div class="chatting-li qtr pink"><div class="portrait"><img src="/Public/main/img/system.jpg"/></div><div class="content"><small><span class="name">客服</span><time>'+time+'</time></small><p>' + content + '</p></div></div>');
        });
    });
</script>
<!--推送-->
<script src="/Public/Home/js/zhicwl-z.js"></script>
<script src="__PUBLIC__/Home/js/cls.js"></script>
</body>
</html>
